package kin.system.util;

import java.lang.reflect.Method;



public class FormatData {
	 public static Object getFieldValue(Object data, String fieldName) {
	        
		  
		  
		  Class clzss = data.getClass();
		  
		  //将字段首字母大写
		  /*String firstWord = fieldName.substring(0, 1).toUpperCase();
		  sb.append(firstWord);
		  sb.append(fieldName.substring(1, fieldName.length()));*/
		  final String methodName = "get" + StringUtil.fristLetterUpperCase(fieldName);
		  Method[] methods = clzss.getDeclaredMethods();
		  try {
		   for (Method method : methods) {
		    // 调用对应的方法
		    if (methodName.equals(method.getName())) {
		     return method.invoke(data, new Object[] {});
		    }
		   }
		  } catch (Exception e) {
		 
		   throw new RuntimeException(e);
		  }
		  return null;
		}
		}
